#include "CMenuBar.h"
#include "CMenu.h"

#include <QApplication>
#include <QDebug>
#include <QToolButton>

#define EXTENSION_NAME "qt_menubar_ext_button"

CMenuBar::CMenuBar(QWidget *parent) : QMenuBar(parent) {
    setFont(qApp->font());
    extension = findChild<QToolButton *>(QLatin1String(EXTENSION_NAME));
    Q_ASSERT(extension);
    extension->setMenu(new CMenu());
}

CMenuBar::~CMenuBar() {
}

QSvgUri CMenuBar::extensionIcon() const {
    return m_extensionIcon;
}

void CMenuBar::setExtensionIcon(const QSvgUri &extensionIcon) {
    m_extensionIcon = extensionIcon;
    extension->setIcon(m_extensionIcon.toIcon());
    emit extensionIconChanged();
}
